package com.ruoyi.system.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SpotsMapper;
import com.ruoyi.system.domain.Spots;
import com.ruoyi.system.service.ISpotsService;

/**
 * 景点Service业务层处理
 *
 * @author Y.C
 * @date 2024-02-21
 */
@Service
public class SpotsServiceImpl extends ServiceImpl<SpotsMapper,Spots> implements ISpotsService
{
    @Autowired
    private SpotsMapper spotsMapper;

    /**
     * 查询景点
     *
     * @param spotId 景点主键
     * @return 景点
     */
    @Override
    public Spots selectSpotsBySpotId(Long spotId)
    {
        return spotsMapper.selectSpotsBySpotId(spotId);
    }

    /**
     * 查询景点列表
     *
     * @param spots 景点
     * @return 景点
     */
    @Override
    public List<Spots> selectSpotsList(Spots spots)
    {
        return spotsMapper.selectSpotsList(spots);
    }

    /**
     * 新增景点
     *
     * @param spots 景点
     * @return 结果
     */
    @Override
    public int insertSpots(Spots spots)
    {
        spots.setCreateTime(DateUtils.getNowDate());
        return spotsMapper.insertSpots(spots);
    }

    /**
     * 修改景点
     *
     * @param spots 景点
     * @return 结果
     */
    @Override
    public int updateSpots(Spots spots)
    {
        spots.setUpdateTime(DateUtils.getNowDate());
        return spotsMapper.updateSpots(spots);
    }

    /**
     * 批量删除景点
     *
     * @param spotIds 需要删除的景点主键
     * @return 结果
     */
    @Override
    public int deleteSpotsBySpotIds(Long[] spotIds)
    {
        return spotsMapper.deleteSpotsBySpotIds(spotIds);
    }

    /**
     * 删除景点信息
     *
     * @param spotId 景点主键
     * @return 结果
     */
    @Override
    public int deleteSpotsBySpotId(Long spotId)
    {
        return spotsMapper.deleteSpotsBySpotId(spotId);
    }

    //查询酒店spot_id和spot_name
    @Override
    public List<Spots> selectSpots() {
        LambdaQueryWrapper<Spots> spotsLambdaQueryWrapper = new LambdaQueryWrapper<>();
        spotsLambdaQueryWrapper.select(Spots::getSpotId,Spots::getSpotName);
        return spotsMapper.selectList(spotsLambdaQueryWrapper);
    }
}
